﻿Date.prototype.format=function(format) {
    var o = {
        "M+": this.getMonth() + 1, 
        "d+": this.getDate(),   
        "h+": this.getHours(),  
        "m+": this.getMinutes(), 
        "s+": this.getSeconds(), 
        "q+": Math.floor((this.getMonth() + 3) / 3), 
        "S": this.getMilliseconds() 

    }
    if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
    (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o) if (new RegExp("(" + k + ")").test(format))
        format = format.replace(RegExp.$1,
      RegExp.$1.length == 1 ? o[k] :
        ("00" + o[k]).substr(("" + o[k]).length));
    return format;
}

function StrToDate(JSONDateString) {
    var date = new Date(parseInt(JSONDateString.replace("/Date(", "").replace(")/", ""), 10));
    return date.format("yyyy-MM-dd hh:mm:ss");
}

//辅料删除事件
function flDelClick(obj) {
    if (confirm("确认要删除?")) {
        $.ajax({
            type: "post",
            url: "/ashx/ProduceEntering.ashx",
            data: { "inputype": "delhlid"
                , delhlid: $(obj).attr("alt")
                , hidOutID: $(".hidoutid").val()
            },
            success: function (msg) {
                var f = msg.substr(0, 1);
                if (f == "1") {
                    $(".btnSave").attr("disabled", false);
                }
                else {
                    $(".btnSave").attr("disabled", true);
                }
                msg = msg.substr(1);
                SetStrArr(msg);
                $(obj).parent().parent().remove();

                upRowsNo("tabfl");
            }
        });
       
    }
}

//损耗删除事件
function shDelClick(obj) {
       if (confirm("确定要删除?")) {
           $.ajax({
               type: "post",
               url: "/ashx/ProduceEntering.ashx",
               data: { "inputype": "delshid"
                        , delshid: $(obj).attr("alt")
                        , hidOutID: $(".hidoutid").val()
               },
               success: function (msg) {
                   var f = msg.substr(0, 1);
                   if (f == "1") {
                       $(".btnSave").attr("disabled", false);
                   }
                   else {
                       $(".btnSave").attr("disabled", true);
                   }
                   msg = msg.substr(1);
                   SetStrArr(msg);
                   $(obj).parent().parent().remove();
                   upRowsNo("tabsh");
               }
           });
          
       }
}


//返还Barcode删除事件
function delClick(obj) {
    if (confirm("确定要删除?")) {
        $.ajax({
            type: "post",
            url: "/ashx/ProduceEntering.ashx",
            data: { "inputype": "delbarid"
                    , delbarid: $(obj).attr("alt")
                    , hidOutID: $(".hidoutid").val()
            },
            success: function (msg) {
                var f = msg.substr(0, 1);
                msg = msg.substr(1);
                if (msg != "-1") {

                    if (f == "1") {
                        $(".btnSave").attr("disabled", false);
                    }
                    else {
                        $(".btnSave").attr("disabled", true);
                    }
                    SetStrArr(msg);
                    $(obj).parent().parent().remove();
                    upRowsNo("tab");
                }
                else {
                    alert("已经入库不能删除");
                }

            }
        });
        //getNwtCur();
    }
}

//修改事件 损耗
function updataSHClick(obj) {
    var shid = $(obj).attr("alt");
    $.ajax({
        type: "post",
        url: "/ashx/ProduceEntering.ashx",
        data: { "inputype": "GetSH", "shid": shid },
        success: function (msg) {
            var unobj = eval('(' + msg + ')');
            $("#txtungc").val(msg.GoodsCode);
            $("#txtunga").val(unobj.GoodsName);
            $("#txtungwt").val(unobj.gwt);
            $("#txtunnwt").val(unobj.nwt);
            $("#txtunqty").val(unobj.qty);
            $("#txtunhw").html(unobj.rubbishcode);
            $("#lblunHwType").val(unobj.rubbishtype);
            $("#tdunldno").val(unobj.continNo);
            $("#tdunmemo").val(unobj.remark);
            $(".hid_unid").val(unobj.id);
            $("#hidungdid").val(unobj.goodsid);

        }
    });
}

//修改事件 消耗
function updataXHClick(obj) {
    var unid = $(obj).attr("alt");
    $.ajax({
        type: "post",
        url: "/ashx/ProduceEntering.ashx",
        data: { "unid": unid },
        success: function (msg) {
            var unobj = eval('(' + msg + ')');
            $("#txtungc").val(msg.GoodsCode);
            $("#txtunga").val(unobj.GoodsName);
            $("#txtungwt").val(unobj.gwt);
            $("#txtunnwt").val(unobj.nwt);
            $("#txtunqty").val(unobj.qty);
            $("#txtunhw").html(unobj.rubbishcode);
            $("#lblunHwType").val(unobj.rubbishtype);
            $("#tdunldno").val(unobj.continNo);
            $("#tdunmemo").val(unobj.remark);
            $(".hid_unid").val(unobj.id);
            $("#hidungdid").val(unobj.goodsid);

        }
    });
}

//修改事件 条形码重复
function updateClick(obj) {

    var barid = $(obj).attr("alt");
    $.ajax({
        type: "post",
        url: "/ashx/ProduceEntering.ashx",
        data: { "barid": barid },
        success: function (msg) {
            var barobj = eval('(' + msg + ')');

            $("#txtgc").val(barobj.goodscode);
            $("#txtgn").val(barobj.goodsname);
            $("#txtgwt").val(barobj.gwt);
            $("#txttare1").val(barobj.tare1);
            $("#txttare2").val(barobj.tare2);
            $("#txtnwt").html(barobj.nwt);
            $("#txtBoxCount").val(barobj.boxcount);
            $("#txtqty").val(barobj.qty);
            $("#txtsid").val(barobj.stroageNo);
            $("#txthw").val(barobj.rubbishcode);
            $("#lblHwType").html(barobj.rubbishtype);
            $("#txtcomeunder").val(barobj.comeunder);
            $("#txtdno").val(barobj.rdh);
            $("#txtpn").val(barobj.packageno);
            $("#lblInDate").html(StrToDate(barobj.createdate));
            $("#txtremark").val(barobj.remark);
            $("#lblBarcode").html(barobj.barcodevalue);
            $(".HidPostion").val(barobj.storageid);
            $("#hidgdid").val(barobj.goodsid);
        }
    });

}


$(document).ready(function () {

    //库位下拉选择根据处理地做筛选
    $("#txtsid").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/ashx/BasicStorage.ashx",
                data: { "word": $("#txtsid").val()
                , "graphic": escape($(".hidOutDepart").val())
                , "belong": escape($(".hidInDepart").val())
                },
                dataType: "json",
                success: function (data) {
                    response(data);
                },
                error: function (result, status) {
                    alert('请输入正确的库位');
                }
            })

        },
        select: function (event, ui) {
            $("#txtsid").val(ui.item.label);
            $(".HidPostion").val(ui.item.value);
            return false;
        },

        minLength: "1"
    });


    //生产返还物品选取
    $("#txtgc").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/ashx/Autocomplete.ashx",
                data: { "goods": $("#txtgc").val(), "type": "T2" },
                dataType: "json",
                success: function (data) {
                    response($.map(data, function (item) {
                        return {
                            label: item.label + " " + item.value,
                            value: item.value,
                            lab: item.label,
                            goodsid: item.goodsid
                        }
                    }));
                },
                error: function (result, status) {
                    alert('请输入正确的物品编码');
                }
            });

        },
        select: function (event, ui) {
            $("#txtgc").val(ui.item.lab);
            $("#txtgn").val(ui.item.value);
            $(".hidgdid").val(ui.item.goodsid);
            return false;
        },
        minLength: "1"
    });





    //生产辅料物品编码选取
    $("#txtgcode_fl").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/ashx/Autocomplete.ashx",
                data: { "goods": $("#txtgcode_fl").val(), "type": "T2" },
                dataType: "json",
                success: function (data) {
                    response($.map(data, function (item) {
                        return {
                            label: item.label + " " + item.value,
                            value: item.value,
                            lab: item.label,
                            goodsid: item.goodsid
                        }
                    }));
                },
                error: function (result, status) {
                    alert('请输入正确的物品编码');
                }
            });

        },
        select: function (event, ui) {
            $("#txtgcode_fl").val(ui.item.lab);
            $("#txtgname_fl").val(ui.item.value);
            $(".hidflid").val(ui.item.goodsid);
            return false;
        },
        minLength: "1"
    });

    //生产损耗物品编码选取
    $("#txtgcode_sh").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/ashx/Autocomplete.ashx",
                data: { "goods": $("#txtgcode_sh").val(), "type": "B" },
                dataType: "json",
                success: function (data) {
                    response($.map(data, function (item) {
                        return {
                            label: item.label + " " + item.value,
                            value: item.value,
                            lab: item.label,
                            goodsid: item.goodsid
                        }
                    }));
                },
                error: function (result, status) {
                    alert('请输入正确的物品编码');
                }
            });

        },
        select: function (event, ui) {
            $("#txtgcode_sh").val(ui.item.lab);
            $("#txtgname_sh").val(ui.item.value);
            // $("#hidshid").val(ui.item.goodsid);
            return false;
        },

        minLength: "1"
    });

    //净重计算
    $("#txttare2,#txttare1,#txtgwt").blur(function () {
        if ($("#txttare1").val() != "" && $("#txtgwt").val() != "" && $("#txttare2").val() != "") {
            $("#txtnwt").html(parseFloat($("#txtgwt").val()) - parseFloat($("#txttare1").val()) - parseFloat($("#txttare2").val()));
        }
    });

    //生产返还插入函数
    function instorage() {
        var remark = $("#txtremark").val()
        var gname = $("#txtgn").val();

        $("#txtgc").focus();
        var jston = {

            "inputype": "barcode",
            "loadnum": $(".inputLoadNum").html(),
            "loadnumid": $(".hiddenloadid").val(),
            "goodscode": $("#txtgc").val(),
            "goodsname": gname,
            "goodsid": $("#hidgdid").val(),
            "comeunder": $("#txtcomeunder").val(),
            "gwt": $("#txtgwt").val(),
            "nwt": $("#txtnwt").val(),
            "tare1": 0,
            "tare2": 0,
            "qty": $("#txtqty").val(),
            "hidInStoID": $(".hidinsid").val(),
            "wrlno": $(".hidwrlno").val(),
            "oper": $(".hiddenOper").val(),
            "vload": $(".inputLoadNum").val(),
            "barcode": $("#lblBarcode").html(),
            "alllock": $("#chkInStr").attr("checked"),
            "islocak": $("#chkIsLock").attr("checked"),
            "inDepart": $(".hidInDepart").val(),
            "storageid": $("#HidPostion").val(),
            "storageno": $("#txtsid").val(),
            "outDepart": $(".hidOutDepart").val(),
            "month": $(".dropMonth").val(),
            "cjoid": $(".hiddencjoid").val(),
            "intype": $(".hidInstype").val(),
            "hidOutID": $(".hidoutid").val(),
            "remark": remark,
            "outsno": $("#EwtsConext_txtSrcOutSid").val()

        };
        $.ajax({
            type: "post",
            url: "/ashx/ProduceEntering.ashx",
            data: jston,
            dataType: "json",
            success: function (msg) {
                var tr = "<tr>";
                tr += "<td>" + ($('#tab tr').length - 1) + "</td>";
                tr += "<td title='" + msg.goodsid + "' class='barcodevalue'>" + msg.goodscode + "</td>";
                tr += "<td>" + gname + "</td>";
                tr += "<td>" + msg.gwt + "</td>";
                tr += "<td class='clsnwt'>" + msg.nwt + "</td>";
                tr += "<td>" + msg.qty + "</td>";
                tr += "<td>" + msg.stroageNo + "</td>";
                tr += "<td>" + remark + "</td>";
                tr += "<td>" + StrToDate(msg.createdate) + "</td>";
                tr += "<td>" + msg.barcodevalue + "</td>";
                tr += "<td><input type='checkbox' class='flase' title='" + msg.id + "' " + GetIsLock(msg.isLocak) + "  />锁定</td>";
                tr += "<td><img src='/images/jian.png'  onclick='javascript:delClick(this)' alt='" + msg.id + "' width='16' height='17' class='jian'/></td>";
                tr += "<td><img src='/images/icons/button_update.gif' onclick='javascript:updateClick(this)' alt='" + msg.id + "' height='17' class='update'/></td>";
                tr += "<td><a href='/Storage/BarcodeSmallImg.aspx?barCodeID=" + msg.id + "' target='_blank'>条码重打</a></td>";
                tr += "</tr>";


                if (msg != null) {
                    $("#tab").append(tr);

                    $(".tdSpanWrlNo").html(msg.gname);  //用gname代替入库单号

                    SetStrArr(msg.remark)
                }

                if (msg.iresult == 1) {

                    $(".btnSave").attr("disabled", false);
                }
                else {

                    $(".btnSave").attr("disabled", true);
                }
                //getNwtCur();
                $(".hidinsid").val(msg.InStrorageID);
                $("#txtgc").val("");
                $("#txtgn").val("");
                $("#dropt").html("");
                $("#txtnwt").val("0");
                $("#txtgn").val("0");
                $("#txtqty").val("");
                $("#txtpn").val("");
                $("#lblBarcode").html("");
                $("#lblInDate").html("");
                $("#txtsid").val("");
                $("#txtBoxCount").val("");
                $("#txthw").val("");
                $("#lblHwType").html("");
                $("#txtcomeunder").val("");
                $(".hiddeninsid").val(msg.InStrorageID);
                $("#chkIsLock").attr("checked", false); //xiehm
                $("#txtremark").val("");
                //打印小标签
                window.open("/Storage/BarcodeSmallImg.aspx?barCodeID=" + msg.id, "_blank");

            }
        });
    }

    //生产返还验证函数
    function InventoryVerification() {
        var strErr2 = "";
        if ($("#txtgc").val() == "") strErr2 += "物品编码不能为空！\n";
        if ($("#txtgn").val() == "") strErr2 += "物品名称不能为空\n";
        if ($("#txtgwt").val() == "" || isNaN($("#txtgwt").val())) strErr2 += "毛重必须输入数字！\n";
        if ($("#txtqty").val() == "" || isNaN($("#txtqty").val())) strErr2 += "数量必须输入数字！\n";
        if ($("#txtqty").val() == "" || isNaN($("#txtqty").val())) strErr2 += "必须选择合法的库位！\n";

        return strErr2;
    }

    //生产返还插入
    $("#btnSaveBarcode").click(function () {
        var strErr = InventoryVerification();
        if (strErr == "") {
            instorage();
        }
        else {
            alert(strErr);
        }
    });

    function GetIsLock(islock) {
        if (islock == true)
            return "checked";
        else {
            return "";
        }
    }

    //checkbox 绑定点击事件
    $(".flase").each(function () {
        $(this).click(function () {
            var id = $(this).attr("title");
            var isLock = "0";
            if ($(this).attr("checked") == "checked")
                isLock = "1";
            else
                isLock = "0";
            updataLock(id, isLock);
        });

    });
    function updataLock(id, isLock) {
        $.ajax({
            type: "post",
            url: "/ashx/Inwrl.ashx",
            data: { barcodeid: id, islock: isLock },
            success: function (msg) {
                alert(msg);
            }
        });
    }
});



//辅料客户端输入验证
function  checkInputFl() {
    var strErr = "";
    if ($("#txtgcode_fl").val() == "") strErr += "物品编码不能为空！\n";
    if ($("#txtgname_fl").val() == "") strErr += "物品名称不能为空！\n";
    if ($("#txtgwt_fl").val() == "" || isNaN($("#txtgwt_fl").val())) strErr += "请输入合法的毛重！\n";
    if ($("#txtnwt_fl").val() == "" || isNaN($("#txtnwt_fl").val())) strErr += "请输入合法的净重！\n";
    if ($("#txtqty_fl").val() == "" || isNaN($("#txtqty_fl").val())) strErr += "请输入合法的数量！\n";
    return strErr;
}

//损耗客户端输入验证
function checkInputSH() {
    var  strErr = "";
    if ($("#txtgcode_sh").val() == "") strErr += "物品编码不能为空！\n";
    if ($("#txtgname_sh").val() == "") strErr += "物品名称不能为空！\n";
    if ($("#txtgwt_sh").val() == "" || isNaN($("#txtgwt_sh").val())) strErr += "请输入合法的毛重！\n";
    if ($("#txtnwt_sh").val() == "" || isNaN($("#txtnwt_sh").val())) strErr += "请输入合法的净重！\n";
    if ($("#txtqty_sh").val() == "" || isNaN($("#txtqty_sh").val())) strErr += "请输入合法的数量！\n";
    return strErr;
}



//辅料插入函数
function flInsert() {
    var strerr = checkInputFl();
    if (strerr != "") {
        alert(strerr);
        return;
    }
    var remark =  $("#txtremark_fl").val();
    $("#txtgcode_fl").focus();
    var jston = {
        "outid": $(".hidoutid").val(),
        "inputype":"fl",
        "gcode_fl": $("#txtgcode_fl").val(),
        "gname_fl": $("#txtgname_fl").val(),
        "gwt_fl": $("#txtgwt_fl").val(),
        "nwt_fl": $("#txtnwt_fl").val(),
        "qty_fl": $("#txtqty_fl").val(),
        "remark_fl":remark,
        "parid": $(".hiddenParSid").val(),
        "cjoid": $(".hiddencjoid").val(),
        "hidInStoID": $(".hidinsid").val(),
        "wrlno": $(".hidwrlno").val(),
     //   "alllock": $("#chkInStr").attr("checked"),
        "oper": $(".hiddenOper").val(),
        "flid": $("#hidflid").val(),
        "load": $(".inputLoadNum").val(),
        "loadnumid": $(".hiddenloadid").val(),
        "inDepart": $(".hidInDepart").val(),
        "outDepart": $(".hidOutDepart").val(),
        "month": $(".hidmonth").val(),
        "intype": $(".hidInstype").val()
    };
    $.ajax({
        type: "post",
        url: "/ashx/ProduceEntering.ashx",
        data: jston,
        success: function (msg) {

            var obj = eval('(' + msg + ')');
            if ($("#hidflid").val() == "0") {
                //新增
                var tr = "<tr>";
                tr += "<td>" + ($('#tabfl tr').length - 1) + "</td>";
                tr += "<td>" + obj.tabno + "</td>";
                tr += "<td>" + obj.goodscode + "</td>";
                tr += "<td>" + obj.goodsname + "</td>";
                tr += "<td>" + obj.gwt + "</td>";
                tr += "<td>" + obj.nwt + "</td>";
                tr += "<td>" + obj.qty + "</td>";
                tr += "<td>" + remark + "</td>";
                tr += "<td><img src='/images/jian.png' onclick='javascript:flDelClick(this)' alt=" + obj.id + " width='16' height='17' class='jian'/></td>";
                tr += "<td><img src='/images/icons/button_update.gif' alt='" + obj.id + "' onclick='javascript:flGet(this)' height='17' class='update'/>";
                tr += "<input id='hid_" + obj.id + "' type='hidden' value='" + obj.id + "' /></td>";

                tr += "</tr>";
                if (obj != null) {
                    $("#tabfl").append(tr);
                    $(".labFlNo").html(obj.tabno);
                    $(".tdSpanWrlNo").html(obj.wrlno);
                    SetStrArr(obj.remark);
                }
            } else {
                //修改显示
                var flid = obj.id;
                var trow = $("#tabfl img[alt='" + flid + "']").parent().parent();
                alert($(trow).html());
                $(trow).find("td").eq(1).html(obj.goodscode);
                $(trow).find("td").eq(2).html(obj.goodsname);
                $(trow).find("td").eq(3).html(obj.gwt);
                $(trow).find("td").eq(4).html(obj.nwt);
                $(trow).find("td").eq(5).html(obj.qty);
                $(trow).find("td").eq(6).html(remark);


            }

            $("#hidflid").val("0");
            $("#txtgcode_fl").val("");
            $("#txtgname_fl").val("");
            $("#txtgwt_fl").val("");
            $("#txtnwt_fl").val("");
            $("#txtqty_fl").val("");
            $("#txtremark_fl").val("");
            $("#btnfl_insert").val("插入");
            if (obj.iresult == 1)
                $(".btnSave").attr("disabled", false);
        }
    });
}



//损耗插入函数
function shInsert() {
    var strerr = checkInputSH();
    if (strerr != "") {
        alert(strerr);
        return;
    }
    var remark = $("#txtremark_sh").val();
    $("#txtgcode_sh").focus();
    var jston = {
        "inputype": "sh",
        "outid": $(".hidoutid").val(),
        "hidOutID": $(".hidoutid").val(),
        "gcode_sh": $("#txtgcode_sh").val(),
        "gname_sh": $("#txtgname_sh").val(),
        "gwt_sh": $("#txtgwt_sh").val(),
        "nwt_sh": $("#txtnwt_sh").val(),
        "qty_sh": $("#txtqty_sh").val(),
        "remark_sh": remark,
        "parid": $(".hiddenParSid").val(),
        "cjoid": $(".hiddencjoid").val(),
        "hidInStoID": $(".hidinsid").val(),
        "wrlno": $(".hidwrlno").val(),
      //  "alllock": $("#chkInStr").attr("checked"),
        "oper": $(".hiddenOper").val(),
        "shid": $("#hidshid").val(),
        "load": $(".inputLoadNum").val(),
        "loadnumid": $(".hiddenloadid").val(),
        "inDepart": $(".hidInDepart").val(),
        "outDepart": $(".hidOutDepart").val(),
        "month": $(".hidmonth").val(),
        "intype": $(".hidInstype").val()
    };

    $.ajax({
        type: "post",
        url: "/ashx/ProduceEntering.ashx",
        data: jston,
        success: function (msg) {
            var obj = eval('(' + msg + ')');
            if ($("#hidshid").val() == "0") {
                var tr = "<tr>";
                tr += "<td>" + ($('#tabsh tr').length - 1) + "</td>";
                tr += "<td>" + obj.tabno + "</td>";
                tr += "<td>" + obj.goodscode + "</td>";
                tr += "<td>" + obj.goodsname + "</td>";
                tr += "<td>" + obj.gwt + "</td>";
                tr += "<td>" + obj.nwt + "</td>";
                tr += "<td>" + obj.qty + "</td>";
                tr += "<td>" + remark + "</td>";
                tr += "<td><img src='/images/jian.png' onclick='javascript:shDelClick(this)' alt=" + obj.id + " width='16' height='17' class='jian'/></td>";
                tr += "<td><img src='/images/icons/button_update.gif' alt='" + obj.id + "' onclick='javascript:shGet(this)' height='17' class='update'/>";
                tr += "<input id='hid_" + obj.id + "' type='hidden' value='" + obj.id + "' /></td>";

                tr += "</tr>";
                if (obj != null) {
                    $("#tabsh").append(tr);
                    $(".tdSpanWrlNo").val(obj.wrlno);
                    SetStrArr(obj.remark);
                    $(".labShNo").html(obj.tabno);
                }
            }
            else {
                //修改显示
                var shid = obj.id;
                var trow = $("#tabsh img[alt='" + shid + "']").parent().parent();
                $(trow).find("td").eq(1).html(obj.goodscode);
                $(trow).find("td").eq(2).html(obj.goodsname);
                $(trow).find("td").eq(3).html(obj.gwt);
                $(trow).find("td").eq(4).html(obj.nwt);
                $(trow).find("td").eq(5).html(obj.qty);
                $(trow).find("td").eq(6).html(remark);



            }

            $("#hidshid").val("0");
            $("#txtgcode_sh").val("");
            $("#txtgname_sh").val("");
            $("#txtgwt_sh").val("");
            $("#txtnwt_sh").val("");
            $("#txtqty_sh").val("");
            $("#txtremark_sh").val("");
            $("#btnShInsert").val("插入");
            if (obj.iresult == 1)
                $(".btnSave").attr("disabled", false);
            else {
                $(".btnSave").attr("disabled", true);
            }
        }
    });
}


function setPlay() {
    $(".cssJY").each(function () { 
    });
}

//取得辅料原数据
function flGet(obj) {
    $("#txtgcode_fl").focus();
    var flid = $(obj).attr("alt");
    var trow = $(obj).parent().parent();
    var goodscode = $(trow).find("td").eq(1).html();

    var goodsname = $(trow).find("td").eq(2).html();
    var gwt = $(trow).find("td").eq(3).html();
    var nwt = $(trow).find("td").eq(4).html();
    var qty = $(trow).find("td").eq(5).html();
    var remark = $(trow).find("td").eq(6).html();

    $("#hidflid").val(flid);
    $("#txtgcode_fl").val(goodscode);
    $("#txtgname_fl").val(goodsname);
    $("#txtgwt_fl").val(gwt);
    $("#txtnwt_fl").val(nwt);
    $("#txtqty_fl").val(qty);
    $("#txtremark_fl").val(remark);
    $("#btnfl_insert").val("修改");
}

//取得损耗源数据
function shGet(obj) {
    $("#txtgcode_sh").focus();
    var shid = $(obj).attr("alt");
    var trow = $(obj).parent().parent();
    var goodscode = $(trow).find("td").eq(1).html();

    var goodsname = $(trow).find("td").eq(2).html();
    var gwt = $(trow).find("td").eq(3).html();
    var nwt = $(trow).find("td").eq(4).html();
    var qty = $(trow).find("td").eq(5).html();
    var remark = $(trow).find("td").eq(6).html();

    $("#hidshid").val(shid);
    $("#txtgcode_sh").val(goodscode);
    $("#txtgname_sh").val(goodsname);
    $("#txtgwt_sh").val(gwt);
    $("#txtnwt_sh").val(nwt);
    $("#txtqty_sh").val(qty);
    $("#txtremark_sh").val(remark);
    $("#btnShInsert").val("修改");
}

function SetStrArr(msg) {
    var str = new Array();
    str = msg.split("|");
    $(".cssladdf").html(str[1]);
    $(".cssradds").html(str[0]);
}


//删除时整表行号更新
function upRowsNo(tabname) {
    var len = 0;
    len = $("#" + tabname + " tr").length;
    for (var i = 2; i < len; i++) {
        $('#' + tabname + ' tr:eq(' + i + ') td:first').text(i - 1);
    }
}
